package emergence.game.hud;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.Border;

import emergence.entities.Player;

public class Sidebar extends JPanel {

    private static final long serialVersionUID = 1L;

    private ChatBox chat;
    private StatBlockViewer viewer;
    private Border border;

    private JPanel chatHolder;
    private JPanel viewerHolder;

    public Sidebar(Player player) {
        this.setLayout(new GridLayout(2, 1));
        chat = new ChatBox();
        viewer = new StatBlockViewer(player);

        chatHolder = new JPanel(new BorderLayout());

        Border raisedBevel = BorderFactory.createRaisedBevelBorder();
        Border loweredBevel = BorderFactory.createLoweredBevelBorder();
        border = BorderFactory.createCompoundBorder(raisedBevel, loweredBevel);

        chatHolder.setBorder(border);
        chatHolder.add(chat, BorderLayout.CENTER);

        viewerHolder = new JPanel(new BorderLayout());
        viewerHolder.setBorder(border);
        viewerHolder.add(viewer, BorderLayout.CENTER);

        this.add(viewerHolder);
        this.add(chatHolder);

    }

    public Insets borderInsets() {
        return border.getBorderInsets(this);
    }

//	@Override
//	public void setMinimumSize(Dimension dim) {
//		super.setMinimumSize(dim);
//		chatHolder.setSize(new Dimension(dim.width, dim.height / 2));
//		viewerHolder.setSize(new Dimension(dim.width, dim.height / 2));
//	}
}
